<div class="tab-pane  active" id="tab_basic">
    <div class="panel panel-default">
        <div class="panel-heading">商品编辑</div>
        <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">人气值</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="subcount" value="{$item['subcount']}" />
                        <div class="help-block">人气值大于20时显示人气图标</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品名称</label>
                    <div class="col-sm-9">
                        <input type="text" name="goodsname" class="form-control" value="{$item['title']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品分类</label>
                    <div class="col-sm-9">
                        <select class="form-control" style="margin-right:15px;" name="pcate" onchange="fetchChildCategory(this.options[this.selectedIndex].value)"  autocomplete="off" class="form-control">
                            <option value="0">请选择分类</option>
                            {loop $category $row}
                            <option value="{$row['id']}" {if $row['id'] == $item['pcate']}
                            selected="selected"{/if}>{$row['name']}</option>
                            {/loop}
                        </select>
                        <div class="help-block">
                            还没有分类，点我 <a href="{php echo $this->createWebUrl('category', array('op' => 'post', 'storeid' => $storeid))}"><i class="fa fa-plus-circle"></i> 添加分类</a>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品限星期购买</label>
                    <div class="col-sm-9">
                        <div style="border:1px #eee dashed; padding:10px;background:#F5F5F5;">
                            <label for="week1" class="checkbox-inline">
                                <input id="week1" type="checkbox" name="week[]" value="1" {if empty($item) || in_array(1, $weeks)}checked{/if}> 星期一
                            </label>
                            <label for="week2" class="checkbox-inline">
                                <input id="week2" type="checkbox" name="week[]" value="2" {if empty($item) || in_array(2, $weeks)}checked{/if}> 星期二
                            </label>
                            <label for="week3" class="checkbox-inline">
                                <input id="week3" type="checkbox" name="week[]" value="3" {if empty($item) || in_array(3, $weeks)}checked{/if}> 星期三
                            </label>
                            <label for="week4" class="checkbox-inline">
                                <input id="week4" type="checkbox" name="week[]" value="4" {if empty($item) || in_array(4, $weeks)}checked{/if}> 星期四
                            </label>
                            <label for="week5" class="checkbox-inline">
                                <input id="week5" type="checkbox" name="week[]" value="5" {if empty($item) || in_array(5, $weeks)}checked{/if}> 星期五
                            </label>
                            <label for="week6" class="checkbox-inline">
                                <input id="week6" type="checkbox" name="week[]" value="6" {if empty($item) || in_array(6, $weeks)}checked{/if}> 星期六
                            </label>
                            <label for="week7" class="checkbox-inline">
                                <input id="week7" type="checkbox" name="week[]" value="0" {if empty($item) || in_array(0, $weeks)}checked{/if}> 星期日
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">打印标签</label>
                    <div class="col-sm-9">
                        <select class="form-control" style="margin-right:15px;" name="labelid"  autocomplete="off" class="form-control">
                            <option value="0">请选择标签</option>
                            {loop $label $row}
                            <option value="{$row['id']}" {if $row['id'] == $item['labelid']} selected="selected"{/if}>{$row['title']}</option>
                            {/loop}
                        </select>
                        <div class="help-block">
                            还没有标签，点我 <a href="{php echo $this->createWebUrl('printlabel', array('op' => 'post', 'storeid' => $storeid))}"><i class="fa fa-plus-circle"></i> 添加标签</a>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品图片</label>
                    <div class="col-sm-9">
                        {php echo tpl_form_field_image('thumb', $item['thumb'])}
                        <span class="help-block" style="color: #f00;">建议尺寸:300*300</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">价格</label>
                    <div class="col-sm-9">
                        <div class="input-group">
                            <input type="text" name="marketprice" class="form-control" value="{$item['marketprice']}" />
                            <span class="input-group-addon">元</span>
                        </div>
                        <div class="help-block">必填</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">会员价格</label>
                    <div class="col-sm-9">
                        <div class="input-group">
                            <input type="text" name="memberprice" class="form-control" value="{$item['memberprice']}" />
                            <span class="input-group-addon">元</span>
                        </div>
                        <div class="help-block"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">原价</label>
                    <div class="col-sm-9">
                        <div class="input-group">
                            <input type="text" name="productprice" class="form-control" value="{$item['productprice']}" />
                            <span class="input-group-addon">元</span>
                        </div>
                        <div class="help-block"></div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">打包费</label>
                    <div class="col-sm-9">
                        <div class="input-group">
                            <input type="text" name="packvalue" class="form-control" value="{$item['packvalue']}" />
                            <span class="input-group-addon">元</span>
                        </div>
                        <div class="help-block"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">每日库存</label>
                    <div class="col-sm-9">
                        <input type="text" name="counts" class="form-control" value="{if empty($item)}-1{else}{$item['counts']}{/if}" />
                        <div class="help-block">-1表示不限制</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">今日已售</label>
                    <div class="col-sm-9">
                        <input type="text" name="today_counts" class="form-control" value="{$item['today_counts']}" />
                        <div class="help-block"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">总销量</label>
                    <div class="col-sm-9">
                        <input type="text" name="sales" class="form-control" value="{$item['sales']}" />
                        <div class="help-block"></div>
                    </div>
                </div>
                {if $_W['role'] != 'operator'}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">购买积分</label>
                    <div class="col-sm-9">
                        <div class="input-group">
                            <input type="text" name="credit" class="form-control" value="{$item['credit']}" />
                            <span class="input-group-addon">分</span>
                        </div>
                        <div class="help-block">购买一份赠送多少积分，不赠送积分请填0。<code>注：只有订单完成后才赠送</code></div>
                    </div>
                </div>
                {/if}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品单位</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="unitname" value="{if empty($item['unitname'])}份{else}{$item['unitname']}{/if}" />
                        <div class="help-block">份、例、斤、半斤、个 等</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品描述</label>
                    <div class="col-sm-9">
                        <textarea style="height:150px;" class="form-control richtext" name="description" cols="70">{$item['description']}</textarea>
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">口味</label>
                    <div class="col-sm-9">
                        <textarea style="height:50px;" class="form-control" name="taste" cols="70">{$item['taste']}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">物料选择</label>
                    <div class="col-sm-9">
                    <div class="input-group form-group">
                          <a class="btn btn-success ng-scope" style="margin-left:20px;" id="addladder" href="javascript:;"><i class="fa fa-plus"></i>增加物料数量</a>
                      </div>
                      <div style="margin: 10px 40px;" id="ladderhtml">
                      {if $item['materials']}
                        {loop $item['materials'] $val}
                            <div class="input-group form-group" >
                                <span class="input-group-addon">物料</span>
                                    <select class="form-control" name="materialid[]">
                                        <option value="0">请选择</option>
                                        {loop $materials $v}
                                        <option value="{$v['id']}" {if $val['materialid']==$v['id']}selected{/if}>{$v['name']}({$v['option']})</option>
                                        {/loop}
                                    </select>
                                <span class="input-group-addon" >数量</span>
                                <input type="text" name="material_num[]"  style="width:100px" class="form-control " value="{$val['material_num']}">
                                <span class="input-group-addon"><a href="javascript:;" class="btn-default btn-sm deleteladder" title="删除"><i class="fa fa-times"></i></a></span>
                            </div> 
                        {/loop}
                      {else}
                            <div class="input-group form-group" >
                                <span class="input-group-addon">物料</span>
                                    <select class="form-control" name="materialid[]">
                                        <option value="0">请选择</option>
                                        {loop $materials $v}
                                        <option value="{$v['id']}" >{$v['name']}({$v['option']})</option>
                                        {/loop}
                                    </select>

                                <span class="input-group-addon" >数量</span>
                                <input type="text" name="material_num[]"  style="width:100px" class="form-control " value="">
                                <span class="input-group-addon"><a href="javascript:;" class="btn-default btn-sm deleteladder" title="删除"><i class="fa fa-times"></i></a></span>
                            </div>  
                      {/if}

                      </div>
                      <span class="help-block">选择该商品所需物料 </span>
                      </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否上架</label>
                    <div class="col-sm-9">
                        <label for="isshow1" class="radio-inline"><input type="radio" name="status" value="1" id="isshow1" {if empty($item) || $item['status'] == 1}checked="true"{/if} /> 是</label>
                        &nbsp;&nbsp;&nbsp;
                        <label for="isshow2" class="radio-inline"><input type="radio" name="status" value="0" id="isshow2"  {if !empty($item) && $item['status'] == 0}checked="true"{/if} /> 否</label>
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
                    <div class="col-sm-9">
                        <input type="text" name="displayorder" class="form-control" value="{$item['displayorder']}" />
                    </div>
                </div>
            </div>
    </div>
</div>
<script type="text/javascript">
$(function(){
    $('#addladder').click(function() {
        var html = '<div class="input-group form-group" >';
            html += '<span class="input-group-addon">物料</span>';
            html += '<select class="form-control" name="materialid[]" id="supplierid">';
            html += '<option value="0">请选择</option>';
            html += '{loop $materials $v}<option value="{$v['id']}" >{$v['name']}({$v['option']})</option>{/loop}';
            html += '</select>';
            html += '<span class="input-group-addon" >数量</span>';
            html += '<input type="text" name="material_num[]"  style="width:100px" class="form-control " value="">';
            html += '<span class="input-group-addon"><a href="javascript:;" class="btn-default btn-sm deleteladder" title="删除"><i class="fa fa-times"></i></a></span>';
            html += '</div>';
        $('#ladderhtml').append(html);
    });
})
$(document).on('click','.deleteladder',function(){
  if(!confirm("确认删除该物料吗?")) {
    return false;
  }
  $(this).parent().parent().remove();
})
</script>